package com.cpi.cornpp.plants.comparator;

import java.util.Comparator;

import com.cpi.cornpp.plants.view.PlantView;

/**
 * Compare List of PlantView
 * @author Edgar Joao
 *
 */
public class PlantElementComparator implements Comparator{

	public int compare(Object plantView, Object plantViewToCompare) {
		int result = 0;
		int plantViewElement = 0;
		int plantViewElementToCompare = 0;
		
		plantViewElement = ((PlantView) plantView).getPlantId();
		plantViewElementToCompare = ((PlantView) plantViewToCompare).getPlantId();
		
		if(plantViewElement < plantViewElementToCompare){
			result = -1;
		}else if(plantViewElement > plantViewElementToCompare){
			result = 1;
		}
		
		return result;
	}

}
